package team.hyznrj.studentsys.entity;

import java.util.ArrayList;
import java.util.List;

public class ExcelObj {
	/*二维数组*/
	private List<ArrayList<String>> list;
	private ExcelHeader header;
	public void setHeader(ExcelHeader header) {
		this.header = header;
	}
	@Override
	public String toString() {
		return "ExcelObj [list=" + list + "]";
	}
	/*默认初始化*/
	public ExcelObj(){
		list=new ArrayList<ArrayList<String>>();
	}
	public ArrayList<String> getHeader(){
		/*默认情况下,[0]作为表头*/
		if(list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
		
	}
	public List<ArrayList<String>> getList() {
		return list;
	}
	/**
	 * 设置表头
	 */
	@Deprecated
	public void setHeader(String []i){
		ArrayList<String> tmp=new ArrayList<String>();
		for(int j=0;j<i.length;j++){
			tmp.add(i[j]);
		}
		/*默认状态下要先把表头移除*/
		if(list.size()>0){
			list.remove(0);
			list.add(0,tmp);
		}else{
			list.add(0,tmp);
		}
	}
	/*增加数据(这里也可以对表头直接操作)*/
	public void put(String []i){
		ArrayList<String> tmp=new ArrayList<String>();
		for(int j=0;j<i.length;j++){
			tmp.add(i[j]);
		}
		list.add(tmp);
	}
	/*增加数据*/
	public void put(ArrayList<String> list){
		if(list!=null){
			this.list.add(list);
		}
	}
	/**
	 * 在index处增加数据
	 */
	public void put(int index,ArrayList<String> list){
		if(list!=null){
			this.list.add(index,list);
		}
	}
	/*输出*/
	public void print(){
		System.out.println("------------------");
		for(int i=0;i<list.size();i++){
			ArrayList<String> arrayList = list.get(i);
			System.out.println(arrayList.toString());
		}
		System.out.println("------------------");
	}

}
